//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "GaussChebyshev2ndPolynomial.h"
using namespace Cephei::QL::Math::Integrals;
#include <gen/QL/Math/Integrals/GaussJacobiPolynomial.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial () : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
    try
    {
#ifdef HANDLE
        _phGaussChebyshev2ndPolynomial = NULL;
#endif
        _ppGaussChebyshev2ndPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial> (new QuantLib::GaussChebyshev2ndPolynomial ( ));
        SetGaussJacobiPolynomial (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial>& childNative, Object^ owner) : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshev2ndPolynomial = NULL;
#endif
	_ppGaussChebyshev2ndPolynomial = &childNative;
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
}
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (QuantLib::GaussChebyshev2ndPolynomial& childNative, Object^ owner) : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshev2ndPolynomial = NULL;
#endif
	_ppGaussChebyshev2ndPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial> (&childNative);
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
    _GaussChebyshev2ndPolynomialOwner = owner;
    _GaussJacobiPolynomialOwner = owner;
}

Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (CGaussChebyshev2ndPolynomial^ copy) : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshev2ndPolynomial = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppGaussChebyshev2ndPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial> (copy->GetShared());
        _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (PLATFORM::Type^ t) : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshev2ndPolynomial = NULL;
#endif
	if (!t->IsSubclassOf(CGaussChebyshev2ndPolynomial::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (QuantLib::Handle<QuantLib::GaussChebyshev2ndPolynomial>& childNative, Object^ owner)  : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
	_phGaussChebyshev2ndPolynomial = &childNative;
	_ppGaussChebyshev2ndPolynomial = &static_cast<boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial>>(childNative.currentLink());
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
    _GaussChebyshev2ndPolynomialOwner = owner;
}
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (QuantLib::Handle<QuantLib::GaussChebyshev2ndPolynomial> childNative)  : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
	_phGaussChebyshev2ndPolynomial = &childNative;
	_ppGaussChebyshev2ndPolynomial = &static_cast<boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial>>(childNative.currentLink());
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::CGaussChebyshev2ndPolynomial (QuantLib::GaussChebyshev2ndPolynomial childNative)  : CGaussJacobiPolynomial(CGaussChebyshev2ndPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshev2ndPolynomial = NULL;
#endif
	_ppGaussChebyshev2ndPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial> (new QuantLib::GaussChebyshev2ndPolynomial (childNative));
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshev2ndPolynomial));
}
#endif

Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::~CGaussChebyshev2ndPolynomial ()
{
    if (_ppGaussChebyshev2ndPolynomial != NULL)
    {
	    delete _ppGaussChebyshev2ndPolynomial;
        _ppGaussChebyshev2ndPolynomial = NULL;
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::!CGaussChebyshev2ndPolynomial ()
{
    if (_ppGaussChebyshev2ndPolynomial != NULL)
    {
	    delete _ppGaussChebyshev2ndPolynomial;
    }
}
QuantLib::GaussChebyshev2ndPolynomial& Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::GetReference ()
{
    if (_ppGaussChebyshev2ndPolynomial == NULL) throw REFNEW NativeNullException ();
	return **_ppGaussChebyshev2ndPolynomial;
}
boost::shared_ptr<QuantLib::GaussChebyshev2ndPolynomial>& Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::GetShared ()
{
    if (_ppGaussChebyshev2ndPolynomial == NULL) throw REFNEW NativeNullException ();
	return *_ppGaussChebyshev2ndPolynomial;
}
QuantLib::GaussChebyshev2ndPolynomial* Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::GetPointer ()
{
    if (_ppGaussChebyshev2ndPolynomial == NULL) throw REFNEW NativeNullException ();
	return &**_ppGaussChebyshev2ndPolynomial;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::GaussChebyshev2ndPolynomial>& Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::GetHandle ()
{
	if (_phGaussChebyshev2ndPolynomial == NULL)
	{
		_phGaussChebyshev2ndPolynomial = new Handle<QuantLib::GaussChebyshev2ndPolynomial> (*_ppGaussChebyshev2ndPolynomial);
	}
	return *_phGaussChebyshev2ndPolynomial;
}
#endif
bool Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial::HasNative () 
{
	return (_ppGaussChebyshev2ndPolynomial != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Math::Integrals::IGaussChebyshev2ndPolynomial^ Cephei::QL::Math::Integrals::CGaussChebyshev2ndPolynomial_Factory::Create ()
{
    return REFNEW CGaussChebyshev2ndPolynomial ();
}
